package com.link2room.rodimus.controller.api;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.rodimus.dto.param.api.CreateNewExpressParamDto;
import com.link2room.rodimus.dto.param.api.CurrentUserExpressListParamDto;
import com.link2room.rodimus.facade.IExpressFacadeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/7/28.9:50
 */
@Api(tags = "发货相关")
@RestController
@RequestMapping("/api/Expresses")
public class ExpressApiController  {

    @Resource
    private IExpressFacadeService expressFacadeService;
    @RequestMapping(value = "/newExpress",method = RequestMethod.POST)
    public BaseResultDto newExpress(@RequestBody CreateNewExpressParamDto paramDto) throws Exception {
        expressFacadeService.newExpress(paramDto);
        BaseResultDto resDto = new BaseResultDto();
        resDto.setResultCode(0);
        return resDto;
    }

    @RequestMapping(method = RequestMethod.GET)
    public BaseResultDto expresses(
            @RequestParam(name = "sourceType",required = false)String sourceType,
            @RequestParam(name = "isDelivered",required = false)String isDelivered,
            @RequestParam(name = "sourceNo",required = false)String sourceNo
    ) throws Exception {
        CurrentUserExpressListParamDto paramDto = new CurrentUserExpressListParamDto();
        paramDto.setSourceType(sourceType);
        paramDto.setIsDelivered(isDelivered);
        paramDto.setSourceNo(sourceNo);
        BaseResultDto resDto = new BaseResultDto();
        resDto.setResultCode(0);
        resDto.setQueryResult(expressFacadeService.currentUserExpressList(paramDto));
        return resDto;
    }

}
